<template>
    <div class="mine">
        <div class="minebg">
            <img class="minebg-img" src="@/assets/images/user/我的.png" alt="">
            <div class="top">
                <div class="topleft">
                    <img class="leftimg" :src="tou" alt="">
                    <div style="position: relative; top: 10px ">
                        <p class="username" v-show="userinfo.nickName">{{ userinfo.nickName }}</p>
                        <p class="usernametext">筛查抢红包</p>
                    </div>
                </div>
                <div class="topright" @click="close">
                    <div>安全退出</div>
                </div>
            </div>
            <div style="width: 100%; display: flex; justify-content: center;">
                <div class="money">
                    <div class="moneyiten"> {{ userinfo.snatchMoney }} 元</div>
                    <div class="moneyiten"> {{ userinfo.withdrawalMoney }} 元</div>
                    <div class="moneyiten"> {{ userinfo.remindMoney }} 元</div>
                </div>
            </div>
        </div>
        <div class="stic" @click="isshowalter()">
            <img class="sticimg" src="@/assets/images/user/我的-提现规则.png" alt="">
            <span> 提示规则</span>
        </div>
        <div class="sticalter" v-show="isshowalterimg">
            <img class="sticalter-img" src="@/assets/images/user/我的-提现规则弹窗.png" alt="">
        </div>
        <div class="userview">
            <div v-if="userinfo.anFlag == 0" @click="godetial">
                <img class="userview-img" src="@/assets/images/user/我的-我要筛查.png" alt="">
            </div>
            <div v-if="userinfo.anFlag == 1" @click="goresult">
                <img class="userview-img" src="@/assets/images/user/我的-查看报告.png" alt="">
            </div>
        </div>
        <tabbar></tabbar>
        <!-- <div class="first" style="background-color: white;border-radius: 20px;" v-if="Object.keys(data).length > 0">
            <div class="" style="display: flex;align-items: center;justify-content: space-around;padding: 10px;">
                <div class="left">
                    <img :src="tou" class="avatar">
                </div>

                <div class="middle">
                    <div class="right_first_line">
                        名称
                        <div class="name">
                            {{ data.data.name }}
                        </div>
                        <div class="xiaozi">筛查抢红包</div>
                    </div>
                </div>
            </div>

            <div class="right">
                <el-button type="primary" round @click="clear">退出登录</el-button>
            </div>
        </div> -->
        <!-- <div class="first" style="background-color: white;border-radius: 20px;" v-else>
            <div class="" style="display: flex;align-items: center;justify-content: space-around;padding: 10px;">
                <div class="left">
                    <img :src="tou" class="avatar">
                </div>

                <div class="middle">
                    <div class="right_first_line">
                        <div class="xiaozi" style="font-size: 13px;">筛查抢红包</div>
                    </div>
                </div>
            </div>

            <div class="right">
                <el-button type="primary" round @click="clear">退出登录</el-button>
            </div>
        </div> -->
        <!-- <div class="money">
            <el-card class="itemmoney" style="margin-right: 5px;">
            <p  class="itemspan">已抢</p >
                <div class="moneymaster">
                    <span class="itemmoneynew">2.7</span><span class="itemmoneynew">元</span> 
                </div>
            </el-card>
            <el-card class="itemmoney">
                <p  class="itemspan">已提现</p >
                    <div class="moneymaster">
                    <span class="itemmoneynew">2.7</span><span class="itemmoneynew">元</span> 
                </div>
            </el-card>
            <el-card class="itemmoney" style="margin-left: 5px;">
            <p class="itemspan">余额</p >
                <div class="moneymaster">
                    <span class="itemmoneynew">2.7</span><span class="itemmoneynew">元</span> 
                </div>
            </el-card>
        </div> -->
        <!-- <div class="static" @click="staticshows">
            <i class="el-icon-warning-outline"></i><span style="margin-left: 5px;">提现规则</span>
        </div>
        <div class="cha" @click="next">
            <img src="https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/ScreeningResult.png" alt="">
        </div> -->
        <!-- <MessageBox></MessageBox> -->
    </div>
</template>

<script>
import tabbar from '@/components/tabbar/tabbar.vue'
import axios from "axios";
import { getredpacket, addburyingpoint, addpacketstep } from '@/api/http.js'
// import MessageBox from '@/components/components/MessageBox/MessageBox.vue'
import {
    getUrl
} from "@/config.js";

export default {

    components: {
        tabbar
    },
    data() {
        return {
            data: {
                sex: '',
            },
            isshowalterimg: false,
            isshowreport: true,
            userinfo: {}
        }
    },

    computed: {

        tou() {
            // let sex = localStorage.getItem('sex')
            // console.log(sex)
            var sexInfo = "";
            console.log(this.userinfo.sex)
            if (this.userinfo.sex == 0) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/boy.jpg"
            }
            if (this.userinfo.sex == 1) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg"
            }
            if (this.userinfo.sex == null) {
                sexInfo = "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/head.png"
            }
            return sexInfo;
            // return 'sex = 1' ? "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg" :
            // 	"https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/boy.jpg";
            // return "https://www.ainaoxingdong.com/api/an-media/images/an/static/personal/girl.jpg"
        },
    },
    methods: {
        //退出登录
        close() {
            console.log(1)
            localStorage.clear();
            this.$router.push({
                path: '/login'
            })
            // localStorage.clear()
        },
        redpacket() {
            getredpacket().then(res => {
                
                this.userinfo = res.data
                console.log(res, '调用了')
            })
        },
        isshowalter() {
            this.isshowalterimg = true
            setTimeout(() => {
                this.isshowalterimg = false
            }, 5000)

        },
        godetial() {
            let obj = { buriedPointName: '我要筛查', function: '1', module: '1', redirectPage: '信息填写页', section: '6', orgNo: '' }
            addburyingpoint(obj).then(res => {
                console.log(res)
            })
            this.$router.push('/message')
        },
        goresult() {
            let obj = { buriedPointName: '查看报告', function: '1', module: '3', redirectPage: '我的页面查看报告', section: '6', orgNo: '' }
            addburyingpoint(obj).then(res => {
                console.log(res)
            })
            this.$router.push('/result')
        },
        report(params = {}) {
            // getReport(params).then(res => {
            // 	const {
            // 		data
            // 	} = res
            // 	this.data = data.data || {}
            // 	console.log('data,', data)
            // })
            
            var baseUrl = getUrl();
            var token = localStorage.getItem("token");
            // axios.get(
            //     baseUrl + "/an/wechat_app/wechat_user/report?token=" + token,
            //     {
            //         js_patientId: params.js_patientId,
            //         js_token: params.js_token
            //     }
            // ).then((res) => {
            //     const {
            //         data
            //     } = res
            //     this.data = data.data || {}
            //     console.log('data,', data)
            // });
        },

        clear() {
            window.localStorage.clear();
            this.$router.push("/login");
        },
        next() {
            this.$router.push({
                path: '/result',
                query: {
                    sex: this.$route.query.sex
                }

            })
        },
        // staticshows() {
        // }
    },
    mounted() {

        let url = encodeURIComponent('activity')
        addpacketstep(url).then(res => {
            console.log(res)
        })
        this.redpacket()
        
        this.report();
    }
}
</script>

<style lang="scss" scoped>
// .money {
//     width: 90%;
//     margin: auto;
//     height: 90px;
//     display: flex;
//     margin-top: 10px;
//     text-align: center;
//     position: relative;
// }
.minebg {
    width: 375px;
    height: 220px;
    position: absolute;
}

.minebg-img {
    width: 100%;
    height: 100%;
}

.top {
    width: 100%;
    position: absolute;
    display: flex;
    justify-content: space-between;
}

.leftimg {
    width: 60px;
    height: 60px;
    margin-left: 30px;
    margin-right: 10px;
    border-radius: 50%;
    border: 2px solid #E8F1FF;
}

.topleft {
    display: flex;
    position: absolute;
    top: -190px;

}

.topright {
    position: absolute;
    font-size: 13px;
    top: -164px;
    right: 30px;
    color: #5599ff;
}

.money {
    width: 290px;
    display: flex;
    position: absolute;
    justify-content: space-between;
    top: 158px;
    font-size: 20px;
}

.moneyiten {
    color: #5599ff;
    font-weight: bold;
    margin-top: 10px;
}

.userview {
    width: 375px;
    height: 76px;
    margin-top: 250px;
    position: absolute;

}

.userview-img {
    width: 100%;
    height: 100%;
}

.username {
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 4px 0;
}

.usernametext {
    font-size: 13px;
    color: #ccc;
}

.stic {
    width: 100%;
    font-size: 12px;
    color: #5599ff;
    text-align: center;
    position: absolute;
    top: 230px;
    z-index: 3;
}

.sticimg {
    width: 12px;
    height: 12px;
}

.sticalter {
    width: 339px;
    height: 154px;
    position: absolute;
    top: 242px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.sticalter-img {
    width: 100%;
    height: 100%;
}

.itemmoney {
    // width: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.itemspan {
    font-size: 12px;
    color: #5599ff;
}

.itemmoneynew {
    font-weight: bold;
    font-size: 18px;
    color: #fff;
}

.moneymaster {
    background-color: #5599ff;
    padding: 10px 5px;
    margin-top: 2px;
    border-radius: 5px;
}

.static {
    padding-top: 10px;
    width: 90%;
    text-align: center;
    margin: auto;
    font-size: 14px;
    color: #5599ff;
}

.staticicon {
    width: 14px;
    height: 14pxs;
}

.mine {

    width: 100%;
    height: 100%;
    background-color: #F9F9F9;
}

.first {
    width: 90%;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 184px;
    background-color: #F9F9F9;

    .left {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 2px solid #E7EFFF;

        img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
        }
    }

    .middle {
        margin-left: 24px;

        .right_first_line {
            // display: flex;
            // width: 100%;
            // justify-content: space-between;

            .name {
                height: 30px;
                font-size: 22px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 900;
                // color: #003941;
                color: rgba(85, 153, 255, 1);
                // line-height: 48px;
            }

            .education {
                line-height: 48px;
            }
        }
    }

    .right {
        // flex: 1;
        padding-right: 10px;
        display: flex;
        justify-content: space-between;


        .right_two_line {
            display: flex;
            flex-direction: column;
            width: 100%;
            align-items: flex-end;
            justify-content: space-between;

            .top {
                width: 150px;
                display: flex;
                align-items: center;
                justify-content: space-between;
            }
        }
    }
}

.xiaozi {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    // color: #336c74;
    color: #B5C3E0;
}

// .left {
//     width: 122px;
//     height: 122px;
//     border-radius: 50%;
//     border: 2px solid #E7EFFF;

//     img {
//         width: 100%;
//         height: 100%;
//         border-radius: 50%;
//     }
// }

// .middle {
//     margin-left: 34px;




//         .name {
//             height: 48px;
//             font-size: 32px;
//             font-family: PingFangSC-Medium, PingFang SC;
//             font-weight: 900;
//             // color: #003941;
//             color: rgba(85, 153, 255, 1);
//             // line-height: 48px;
//         }

//         .education {
//             line-height: 48px;
//         }
// }

.cha {
    width: 287px;
    height: 79px;
    display: block;
    border-radius: 40px;
    box-shadow: 4px 6px 18px 0px rgba(30, 90, 102, 0.1);
    margin: 20px auto;
}

.cha img {
    width: 100%;
    height: 100%;
}
</style>